package com.gz.droolsrule.service;

import com.github.pagehelper.PageInfo;
import com.github.pagehelper.util.StringUtil;
import com.gz.droolsrule.dao.BaseRuleSceneEntityRelInfoMapper;
import com.gz.droolsrule.pojo.BaseRuleEntityInfo;
import com.gz.droolsrule.pojo.BaseRuleSceneEntityRelInfo;
import com.gz.droolsrule.pojo.BaseRuleSceneInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ProjectName: drools-rule
 * @Package: com.drools.rules.gz.droolsrule.service
 * @ClassName: RuleSceneEntityRelService
 * @Author: gz
 * @Description:
 * @Date: 2019/5/29 21:56
 * @Version: 1.0
 */
@Service
public class RuleSceneEntityRelService {
    @Autowired
    private BaseRuleSceneEntityRelInfoMapper baseRuleSceneEntityRelInfoMapper;

    /**
     * 方法说明: 查询场景与实体关系表信息
     *
     * @param baseRuleSceneEntityRelInfo 参数
     * @param page                       分页参数
     */
    public List<BaseRuleSceneEntityRelInfo> findBaseRuleSceneEntityRelInfoList(BaseRuleSceneEntityRelInfo baseRuleSceneEntityRelInfo, PageInfo page) {
        return this.baseRuleSceneEntityRelInfoMapper.findBaseRuleSceneEntityRelInfoList(baseRuleSceneEntityRelInfo);
    }

    /**
     * 方法说明: 根据场景信息获取相关的实体信息
     *
     * @param baseRuleSceneInfo 参数
     */
    public List<BaseRuleEntityInfo> findBaseRuleEntityListByScene(BaseRuleSceneInfo baseRuleSceneInfo)  {
        //判断参数
        if (null == baseRuleSceneInfo || (StringUtil.isEmpty(baseRuleSceneInfo.getSceneIdentify()) &&
                null == baseRuleSceneInfo.getSceneId())) {
            return null;
        }
        //查询数据
        return this.baseRuleSceneEntityRelInfoMapper.findBaseRuleEntityListByScene(baseRuleSceneInfo);
    }
}
